package br.upis.pf1.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import br.upis.pf1.entity.Cliente;
import br.upis.pf1.entity.Evento;
import br.upis.pf1.entity.Login;
import br.upis.pf1.entity.Pagamento;
import br.upis.pf1.entity.Plano;

public class HibernateUtil {

	private static SessionFactory sessionFactory;
	
	static  {
		try {
			sessionFactory = new AnnotationConfiguration().
					addAnnotatedClass(Login.class).
					addAnnotatedClass(Cliente.class).
					addAnnotatedClass(Evento.class).
					addAnnotatedClass(Plano.class).
					addAnnotatedClass(Pagamento.class).
					configure().buildSessionFactory();
		} catch (Exception e) {
			throw new ExceptionInInitializerError(e);
		}
	}
	
	public static Session getSession() {
		return sessionFactory.openSession();
	}
	
}
